package com.gitee.wsl.transform.validator.func

import com.gitee.wsl.transform.validator.ValidatorWithTransform

fun <INPUT, OUTPUT, A, B, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    f: (A, B) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> = zip(p1, p2).map { (a, b) -> f(a, b) }

fun <INPUT, OUTPUT, A, B, C, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    f: (A, B, C) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> = zip(p1, p2, p3).map { (a, b, c) -> f(a, b, c) }

fun <INPUT, OUTPUT, A, B, C, D, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    f: (A, B, C, D) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> = zip(p1, p2, p3, p4).map { (a, b, c, d) -> f(a, b, c, d) }

fun <INPUT, OUTPUT, A, B, C, D, E, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    p5: ValidatorWithTransform<INPUT, E, ERROR>,
    f: (A, B, C, D, E) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> = zip(p1, p2, p3, p4, p5).map { (a, b, c, d, e) -> f(a, b, c, d, e) }

fun <INPUT, OUTPUT, A, B, C, D, E, F, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    p5: ValidatorWithTransform<INPUT, E, ERROR>,
    p6: ValidatorWithTransform<INPUT, F, ERROR>,
    f: (A, B, C, D, E, F) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> = zip(p1, p2, p3, p4, p5, p6).map { (a, b, c, d, e, f) -> f(a, b, c, d, e, f) }

fun <INPUT, OUTPUT, A, B, C, D, E, F, G, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    p5: ValidatorWithTransform<INPUT, E, ERROR>,
    p6: ValidatorWithTransform<INPUT, F, ERROR>,
    p7: ValidatorWithTransform<INPUT, G, ERROR>,
    f: (A, B, C, D, E, F, G) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> =
   zip(p1, p2, p3, p4, p5, p6, p7).map { (a, b, c, d, e, f, g) -> f(a, b, c, d, e, f, g) }

fun <INPUT, OUTPUT, A, B, C, D, E, F, G, H, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    p5: ValidatorWithTransform<INPUT, E, ERROR>,
    p6: ValidatorWithTransform<INPUT, F, ERROR>,
    p7: ValidatorWithTransform<INPUT, G, ERROR>,
    p8: ValidatorWithTransform<INPUT, H, ERROR>,
    f: (A, B, C, D, E, F, G, H) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> =
   zip(p1, p2, p3, p4, p5, p6, p7, p8).map { (a, b, c, d, e, f, g, h) -> f(a, b, c, d, e, f, g, h) }

fun <INPUT, OUTPUT, A, B, C, D, E, F, G, H, I, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    p5: ValidatorWithTransform<INPUT, E, ERROR>,
    p6: ValidatorWithTransform<INPUT, F, ERROR>,
    p7: ValidatorWithTransform<INPUT, G, ERROR>,
    p8: ValidatorWithTransform<INPUT, H, ERROR>,
    p9: ValidatorWithTransform<INPUT, I, ERROR>,
    f: (A, B, C, D, E, F, G, H, I) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> =
   zip(p1, p2, p3, p4, p5, p6, p7, p8, p9).map { (a, b, c, d, e, f, g, h, i) ->
      f(a, b, c, d, e, f, g, h, i)
   }

fun <INPUT, OUTPUT, A, B, C, D, E, F, G, H, I, J, ERROR> ValidatorWithTransform.Companion.compose(
    p1: ValidatorWithTransform<INPUT, A, ERROR>,
    p2: ValidatorWithTransform<INPUT, B, ERROR>,
    p3: ValidatorWithTransform<INPUT, C, ERROR>,
    p4: ValidatorWithTransform<INPUT, D, ERROR>,
    p5: ValidatorWithTransform<INPUT, E, ERROR>,
    p6: ValidatorWithTransform<INPUT, F, ERROR>,
    p7: ValidatorWithTransform<INPUT, G, ERROR>,
    p8: ValidatorWithTransform<INPUT, H, ERROR>,
    p9: ValidatorWithTransform<INPUT, I, ERROR>,
    p10: ValidatorWithTransform<INPUT, J, ERROR>,
    f: (A, B, C, D, E, F, G, H, I, J) -> OUTPUT,
): ValidatorWithTransform<INPUT, OUTPUT, ERROR> =
   zip(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10).map { (a, b, c, d, e, f, g, h, i, j) ->
      f(a, b, c, d, e, f, g, h, i, j)
   }
